package com.example.demo.service;

import com.example.demo.dao.TbUserDAO;
import com.example.demo.entity.TbUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TbUserServiceImpl implements TbUserService{
    @Autowired
    private TbUserDAO tbUserDAO;
    @Override
    public List<TbUser> findAll() {
        return tbUserDAO.findAll();
    }

    @Override
    public String add(TbUser user) {
        int status = tbUserDAO.add(user);
        if (status>0){
            return "插入成功";
        }
        else {
            return "插入失败";
        }
    }


    public String updateUser(TbUser user){
        int status=tbUserDAO.updateUser(user);
        if (status>0){
            return "更新成功";
        }else {
            return "更新失败";
        }
    }

    @Override
    public String delUser(int id) {
        int status=tbUserDAO.delUser(id);
        if (status>0){
            return "删除成功";
        }else {
            return "删除失败";
        }
//        return null;
    }
}
